package com.aierkeji.call.b2c.service;

import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.aierkeji.call.b2c.dao.jpa.AkjCallClueHistoryDao;
import com.aierkeji.call.b2c.entity.AkjCallClueHistroyVo;
import com.aierkeji.call.b2c.util.DateTimeUtils;
import com.aierkeji.call.b2c.util.ResultMapHelper;
import com.aierkeji.call.b2c.util.StringUtils;

@Service
public class AkjCallClueHistoryService {
	private final Logger log = LogManager.getLogger(getClass());
	
	@Autowired
	private AkjCallClueHistoryDao akjCallClueHistoryDao;
	
	
	public Map<String, Object> findCallClueHistroyById(Map<String, Object> map) {
		
		String callClueId 	= (String)map.get("callClueId");
		String createdAt 	= (String)map.get("seacrDate");
		if(StringUtils.isEmpty(callClueId)) {
			return ResultMapHelper.nullParamsResult();
		}
		if(StringUtils.isEmpty(createdAt)) {
			createdAt =DateTimeUtils.converDateToString( DateTimeUtils.getCurrentTime(),DateTimeUtils.DATE_PATTERN_DAY);
		}
		String initTodayStr = createdAt+" 00:00:00";
		String finish	 = createdAt+" 23:59:59";
		
		List<AkjCallClueHistroyVo> historyList = akjCallClueHistoryDao.findHistroyByCallClueId(callClueId, initTodayStr,finish);
		
		return ResultMapHelper.success(historyList);
	}

}
